clc;
clearvars();

%%
BasePlotFileName='Plots\DecisionsAndFeaturesAnalys';
SavePlots=0;
TextSize=14;
%%
MBDataset=load('..\CodesV15NewRunForDoubleCheck\Data\FullyMBDataset.mat');
MFDataset=load('..\CodesV15NewRunForDoubleCheck\Data\FullyMFDataset.mat');

%%
FIndex=[6,7];
% FIndex=1:27;
FMean(:,1)=mean(MBDataset.Features(:,FIndex));
FMean(:,2)=mean(MFDataset.Features(:,FIndex));
Std(:,1)=std(MBDataset.Features(:,FIndex));
Std(:,2)=std(MFDataset.Features(:,FIndex));
n=length(FIndex);

%%
figure(1);clf();
b=bar(FMean,1);
hold on;
h=errorbar((1:n)-0.15,FMean(:,1),Std(:,1),'r','color','black','linewidth',3);
set(h,'linestyle','none');
h=errorbar((1:n)+0.15,FMean(:,2),Std(:,2),'r','color','black','linewidth',3);
set(h,'linestyle','none');

b(1).FaceColor = 'b';
b(2).FaceColor = 'r';
set(gca,'XTick',1:n);
set(gca,'XTickLabel',MFDataset.FeaturesName(FIndex));
set(gca,'XTickLabelRotation',90);
ylim([0.5,1]);
legend('MB','MF','Location','northeastoutside')
% scatter(MBDataset.Features(:,F1Index),MBDataset.Features(:,F2Index),'b')
% hold on
% scatter(MFDataset.Features(:,F1Index),MFDataset.Features(:,F2Index),'r')
hold off
set(gcf,'Position',[10    50    600    300]);
%%
TTestMat=ones(n);
PValuMat=zeros(n);
for i=1:n
    for j=i:n
        [TTestMat(i,j),PValuMat(i,j)]=ttest(MFDataset.Features(:,FIndex(i)),MBDataset.Features(:,FIndex(j)));
    end
end
disp(TTestMat)
disp(PValuMat)
%%

if SavePlots
FileName=[BasePlotFileName,'NBBFeatures']; %#ok<*UNRCH>
saveas(gcf,[FileName,'.jpg']);
saveas(gcf,[FileName,'.emf']);
end